package gui;

import java.util.ArrayList;
import java.util.List;
import javax.inject.Named;
import javax.enterprise.context.RequestScoped;
import utils.MessageCode;

@Named(value = "logBean")
@RequestScoped
public class LogBean {
    
    private final String noInvitationSuccededMessage = "No invitation sent. Please check if"
            + "the users were already invited or they were already joining the event.";
    private final String someInvitationSuccededMessage = "Some invitation failed. Please check if"
            + "the users were already invited or they were already joining the event.";
    private final String everyInvitationSuccededMessage = "Invitations sent successfully.";
    private final String invitationAcceptedMessage = "You accepted the invitation. Now you are a participant. "
            + "The event is now in your calendar, and you can see its details.";
    private final String invitationRefusedMessage = "You refused the invitation. You won't be able to "
            + "participate to the event unless the creator invites you again.";
    private final String participationCancelledMessage = "You cancelled your participation. The event is now "
            + "removed from your calendar.";
    private final String eventPostponedMessage = "You decided to postpone the event. Every participant will be "
            + "notified.";
    private final String profileCancelledMessage = "You are no more registered to MeteoCal. Goodbye. "
            + "(We hope you change your mind though...)";
    
    
    private String messageCode;
    private String usernames;
    private List<String> userList;
    
    public LogBean() {
        userList = new ArrayList<>();
    }
    
    public void loadMessage() {
        if (usernames != null && !usernames.isEmpty()) {
            for (String username : usernames.split(" ")) {
                userList.add(username);
            }
        }
    }

    public String getMessageCode() {
        return messageCode;
    }

    public void setMessageCode(String messageCode) {
        this.messageCode = messageCode;
    }

    public String getUsernames() {
        return usernames;
    }

    public void setUsernames(String usernames) {
        this.usernames = usernames;
    }

    public List<String> getUserList() {
        return userList;
    }

    public void setUserList(List<String> userList) {
        this.userList = userList;
    }

    public String getNoInvitationSuccededMessage() {
        return noInvitationSuccededMessage;
    }

    public String getSomeInvitationSuccededMessage() {
        return someInvitationSuccededMessage;
    }

    public String getEveryInvitationSuccededMessage() {
        return everyInvitationSuccededMessage;
    }

    public String getInvitationAcceptedMessage() {
        return invitationAcceptedMessage;
    }

    public String getInvitationRefusedMessage() {
        return invitationRefusedMessage;
    }

    public String getParticipationCancelledMessage() {
        return participationCancelledMessage;
    }

    public String getEventPostponedMessage() {
        return eventPostponedMessage;
    }

    public String getProfileCancelledMessage() {
        return profileCancelledMessage;
    }
    
    public boolean isNoInvitationSucceded() {
        return MessageCode.NO_USER_INVITED.toString().equalsIgnoreCase(messageCode);
    }
    
    public boolean isSomeInvitationSucceded() {
        return MessageCode.SOME_USER_INVITED.toString().equalsIgnoreCase(messageCode);
    }
    
    public boolean isEveryInvitationSucceded() {
        return MessageCode.EVERY_USER_INVITED.toString().equalsIgnoreCase(messageCode);
    }
    
    public boolean isInvitationAccepted() {
        return MessageCode.INVITATION_ACCEPTED.toString().equalsIgnoreCase(messageCode);
    }
    
    public boolean isInvitationRefused() {
        return MessageCode.INVITATION_REFUSED.toString().equalsIgnoreCase(messageCode);
    }
    
    public boolean isParticipationCancelled() {
        return MessageCode.PARTICIPATION_CANCELLED.toString().equalsIgnoreCase(messageCode);
    }
    
    public boolean isEventPostponed() {
        return MessageCode.EVENT_POSTPONED.toString().equalsIgnoreCase(messageCode);
    }
    
    public boolean isProfileCancelled() {
        return MessageCode.PROFILE_CANCELLED.toString().equalsIgnoreCase(messageCode);
    }
}
